<?
/*  公共的类，目前主要用来处理一些连接
*/
class PublcJsAction extends Action {
  function _initialize() {

  }

  /*  获取头部，group-member-base.html中调用
   * <script language="javascript" type="text/javascript">
      document.write('<script src="/main/public.php/circle/gourpLine/cyid/{$cyid}"><'+'/script>');
    </script>
  */
  public function gourpLine() {
    $cyid = $_GET["cyid"];
    $m = M();
    $sql = "select t1.id as cyid,t1.cname as name, t2.id as style_id, t2.cname as style_name, t3.id as style_up_id, t3.cname as style_up_name
      from pw_colonys t1
      left join pw_cnstyles t2 on (t1.styleid = t2.id)
      left join pw_cnstyles t3 on (t2.upid = t3.id)
      where t1.id = $cyid";
    $result = $m->query($sql);
    $result = $result[0];
    $str .= '<a href="/index.html">首页</a> => <a href="/bbs">社区</a> => ';
    if($result["style_up_name"]) $str .= '<a href="/pw8/apps.php?q=groups&q=groups&a=all&styleid='.$result['style_up_id'].'">'.$result["style_up_name"].'</a> =>';
    $str .= '<a href="/pw8/apps.php?q=groups&q=groups&a=all&styleid='.$result['style_id'].'">'.$result["style_name"].'</a> => '.$result["name"];
    echo "document.write('$str')";
  }

  //上面的简化，不需要群组的成条line了，只需要群组名称
  public function getGroupInfo() {
    $cyid = $_GET['cyid'];
    $m = M('PwColonys');
    $result = $m->where('id='.$cyid)->find();
    $str .= '<a href="/bbs">社区首页</a> >> <a href="/bbs/group_'.$result['id'].'.html">'.$result['cname'].'</a>';
	if(!empty($_GET['aid'])){
	  $m=M('APwColonysArticle');
	  $article=$m->find($_GET['aid']);
	  $str.=">>".$article['title'];
	 }
    echo "document.write('$str')";
  }


  /*  获取个人专栏信息
      $columns = array(
      1=>array(column_type=>1),//社区首页=>***个人专栏
      2=>array(column_type=>2,sub_id=>0),//社区首页=>***个人专栏=>***(具体文章标题)
      3=>array(column_type=>3),//社区首页=>***个人专栏=>相册
      4=>array(column_type=>4,sub_id=>0),//社区首页=>***个人专栏=>相册=>****（相册名称）
    );
  */
  public function getColumnInfo() {
    $uid = $_GET['uid'];
    $type = $_GET['column_type'];
    $id = $_GET['sub_id'];
    $m = M('PwMembers');
    $user = $m->find($uid);
    $str .= '<a href="/bbs">社区首页</a> » <a href="/column/u_'.$uid.'.html">'.$user['username'].'</a>';
    if ($type == 1) {

    }
    else if ($type == 2) {
      $m = M('PwDiary');
      $diary = $m->find($id);
      $str .= ' » '.$diary['subject'];
    }
    else if ($type == 3) $str .= ' » 相册';
    else if ($type == 4) {
      $m = M('PwCnalbum');
      $cnalbum = $m->find($id);
      $str .= ' » <a href="/column/album_'.$uid.'.html">相册</a> » '.$cnalbum['aname'];
    }
    else $str ='';
    echo "document.write('$str')";
  }
}


?>